package ioTest;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;

/**
 * 转换流写出字符
 */
public class OSWDemo {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("osw.txt");
        //创建转换流时通常指定第2个参数来明确字符集,以此来保证跨平台性
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        osw.write("心在跳是爱情如烈火");
        osw.write("爱如火温暖了心窝");
        System.out.println("写出完成");
        osw.close();

















    }
}
